package com.gimi.cloud.mmf.user.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;


@Entity
@Table(name = "test_user")
public class TestUser implements Serializable{

	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	private String userName;
	private Integer age;
	
	@Temporal(TemporalType.TIMESTAMP)
	@CreationTimestamp
	@Column(insertable = true, updatable = false)
	private Date insertTime;
	
	@Temporal(TemporalType.TIMESTAMP)
	@UpdateTimestamp
	@Column(insertable = false, updatable = true)
	private Date updateTime;
	
	@OneToMany(fetch=FetchType.LAZY, mappedBy="testUser", cascade=CascadeType.ALL)
	private List<TestCapitalLog> testCapitalLogs;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public Date getInsertTime() {
		return insertTime;
	}

	public void setInsertTime(Date insertTime) {
		this.insertTime = insertTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	
	public List<TestCapitalLog> getTestCapitalLogs() {
		return testCapitalLogs;
	}

	public void setTestCapitalLogs(List<TestCapitalLog> testCapitalLogs) {
		this.testCapitalLogs = testCapitalLogs;
	}

	@Override
	public String toString() {
		return "TestUser [id=" + id + ", userName=" + userName + ", age=" + age + ", insertTime=" + insertTime
				+ ", updateTime=" + updateTime + ", testCapitalLogs=" + testCapitalLogs.toString() + "]";
	}
	
	
	
}
